import { CommonForm } from "@/pages/OrderModule/common/components/CommonForm";
import { CommonModal } from "@/views/components/CommonModal";
// import CommonInputNumber from "@/pages/OrderModule/common/components/CommonInputNumber";
import {
	PrefixPlaceholder,
	Input,
	Select,
	PreInputNumber,
	CommonInput,
	CommonInputNumber
} from "@/views/components/PrefixPlaceholder";
import { Form, message } from "antd";
import { updatePriceSku } from "@/pages/GoodsModule/systemGoods/service";

function SkuRemarkModal(props) {
	const { fetchList, selectedRows, onCancel, placeholder, prefix = "会员价", isSkuType, skuList } = props;
	const [form] = Form.useForm();
	function handleOk() {
		form.validateFields().then(values => {
			updatePriceSku({
				ids: isSkuType ? selectedRows.map(e => e.id): skuList,
				...form.getFieldsValue(),
				// type  1 成本价  2 采购价 3会员价
				type: 3
			}).then(res => {
				const { success, msg } = res;
				if (success) {
					message.success(msg);
					fetchList();
					onCancel();
				}
			});
		});
	}

	return (
		<CommonModal title={{ title: "修改价格" }} open={true} width="400px" onOk={handleOk} onCancel={onCancel}>
			<CommonForm
				formProps={{
					form
				}}
				columns={[
					{
						Component: CommonInputNumber,
						name: "price",

						rules: [{ required: true, message: "价格不能为空" }],
						props: {
							placeholder: placeholder || "会员价",
							min: 0.01,
							precision: 2,
							controls: false,
							prefix: prefix
						}
					}
				]}
			></CommonForm>
		</CommonModal>
	);
}

export default SkuRemarkModal;
